using System.Collections.Generic;
using NUnit.Framework;

// ReSharper disable InconsistentNaming
namespace NFreeMarker.Tests.Template
{
    public class TemplateTests_ProcessBuiltInsForHashes
    {
        [TestFixture]
        public class When_processing_a_keys_builtin : TemplateTestsBase
        {
            [Test]
            public void Assure_the_key_values_are_returned()
            {
                SetTemplateContent(
                    "<#list dict?keys as key>" +
                    "[${key}]" +
                    "</#list>");
                AddTemplateVariable("dict", new Dictionary<string, string>
                {
                    {"A", "1"},
                    {"B", "2"},
                    {"C", "3"}
                });

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("[A][B][C]"));
            }
        }

        [TestFixture]
        public class When_processing_a_values_builtin : TemplateTestsBase
        {
            [Test]
            public void Assure_the_key_values_are_returned()
            {
                SetTemplateContent(
                    "<#list dict?values as value>" +
                    "[${value}]" +
                    "</#list>");
                AddTemplateVariable("dict", new Dictionary<string, string>
                {
                    {"A", "1"},
                    {"B", "2"},
                    {"C", "3"}
                });

                string output = ProcessTemplate();

                Assert.That(output, Is.EqualTo("[1][2][3]"));
            }
        }
    }
}
// ReSharper enable InconsistentNaming
